const tokenKey = "xxxxx-Token";
const permCodeKey = "xxxxx-Code";

export function getToken() {
  return window.localStorage.getItem(tokenKey);
}

export function setToken(token) {
  return window.localStorage.setItem(tokenKey, token);
}

export function removeToken() {
  window.localStorage.removeItem(tokenKey);
}

export function getPermCodes() {
  const permCodes = window.localStorage.getItem(permCodeKey);
  if (typeof permCodes === "string") {
    return JSON.parse(permCodes);
  }
  return null;
}

export function setPermCodes(codes) {
  return window.localStorage.setItem(permCodeKey, JSON.stringify(codes));
}

export function removePermCodes() {
  window.localStorage.removeItem(permCodeKey);
}

export function clearStorageInfo() {
  removeToken();
  removePermCodes();
}
